package com.gs.login.service;

import com.gs.login.dao.UserRepository;
import com.gs.login.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description
 * @Author heartstring
 * @Date 2020/5/21
 */
@Service
public class UserSevice {

    @Autowired
    private UserRepository userRepository;

    @Transactional
    public User addUser(User user)
    {
        Integer id = userRepository.addUser(user);
        user.setId(id);
        return user;
    }

    public User getByUserName(String userName)
    {
       return  userRepository.findByUsername(userName);
    }
}
